#include "viewfirstinfo.h"
#include "ui_viewfirstinfo.h"

viewFirstInfo::viewFirstInfo(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::viewFirstInfo)
{
    ui->setupUi(this);
}

viewFirstInfo::load(QString visit_time, QString first_symptom, int first_age, QString elapsed_time, QString height, QString weight, QString smoking_history, QString previous_illnesses, QString comorbidity, QString thymic_disease, QString myasthenia, QString antibody_test, QString blood_test, QString technical_inspection, QString scale_evaluation1, QString scale_evaluation2, QString diagnosis1, QString diagnosis2, QString treatment_plan, QString MGFA)
{
    ui->label_25->clear();
    ui->label_26->clear();
    ui->label_27->clear();
    ui->label_28->clear();
    ui->label_29->clear();
    ui->label_30->clear();
    ui->label_31->clear();
    ui->label_32->clear();
    ui->label_33->clear();
    ui->label_34->clear();
    ui->label_35->clear();
    ui->label_20->clear();
    ui->label_42->clear();
    ui->label_22->clear();
    ui->textEdit_2->clear();
    ui->label_23->clear();
    ui->textEdit_4->clear();
    ui->label_24->clear();
    ui->textEdit_5->clear();
    ui->label_36->clear();

    ui->label_25->setText(visit_time);
    ui->label_26->setText(first_symptom);
    ui->label_27->setText(QString::number(first_age));
    ui->label_28->setText(elapsed_time);
    ui->label_29->setText(height);
    ui->label_30->setText(weight);
    ui->label_31->setText(smoking_history);
    if(QString::compare(previous_illnesses, "") == 0)
    {
        previous_illnesses = "无";
    }
    ui->label_32->setText(previous_illnesses);
    if(QString::compare(comorbidity, "") == 0)
    {
        comorbidity = "无";
    }
    ui->label_33->setText(comorbidity);
    if(QString::compare(thymic_disease, "") == 0)
    {
        thymic_disease = "未查";
    }
    ui->label_34->setText(thymic_disease);
    if(QString::compare(myasthenia, "") == 0)
    {
        myasthenia = "无";
    }
    ui->label_35->setText(myasthenia);
    if(QString::compare(antibody_test, "") == 0)
    {
        antibody_test = "无";
        ui->label_20->setText(antibody_test);
    }
    else
    {
        //加载图片
        QImage image;
        image.load(antibody_test);
        QPixmap pixmap = QPixmap::fromImage(image);
        int width = ui->label_20->width();
        int height = ui->label_20->height();
        QPixmap fitpixmap = pixmap.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        ui->label_20->setPixmap(fitpixmap);
    }
    if(QString::compare(blood_test, "") == 0)
    {
        blood_test = "无";
        ui->label_42->setText(blood_test);
    }
    else
    {
        //加载图片
        QImage image;
        image.load(blood_test);
        QPixmap pixmap = QPixmap::fromImage(image);
        int width = ui->label_42->width();
        int height = ui->label_42->height();
        QPixmap fitpixmap = pixmap.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        ui->label_42->setPixmap(fitpixmap);
    }
    if(QString::compare(technical_inspection, "") == 0)
    {
        technical_inspection = "无";
        ui->label_22->setText(technical_inspection);
    }
    else
    {
        //加载图片
        QImage image;
        image.load(technical_inspection);
        QPixmap pixmap = QPixmap::fromImage(image);
        int width = ui->label_22->width();
        int height = ui->label_22->height();
        QPixmap fitpixmap = pixmap.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        ui->label_22->setPixmap(fitpixmap);
    }
    ui->textEdit_2->setText(scale_evaluation1);
    //加载图片
    if(QString::compare(scale_evaluation2, "") != 0)
    {
        QImage image;
        image.load(scale_evaluation2);
        QPixmap pixmap = QPixmap::fromImage(image);
        int width = ui->label_23->width();
        int height = ui->label_23->height();
        QPixmap fitpixmap = pixmap.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        ui->label_23->setPixmap(fitpixmap);
    }
    ui->textEdit_4->setText(diagnosis1);
    //加载图片
    if(QString::compare(diagnosis2, "") != 0)
    {
        QImage image;
        image.load(diagnosis2);
        QPixmap pixmap = QPixmap::fromImage(image);
        int width = ui->label_24->width();
        int height = ui->label_24->height();
        QPixmap fitpixmap = pixmap.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        ui->label_24->setPixmap(fitpixmap);
    }
    ui->textEdit_5->setText(treatment_plan);
    if(QString::compare(MGFA, "") == 0)
    {
        MGFA = "无干预";
    }
    ui->label_36->setText(MGFA);
}

viewFirstInfo::~viewFirstInfo()
{
    delete ui;
}

void viewFirstInfo::on_btn_cancel_clicked()
{
    this->hide();
}
